<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    //闭包可以缓存数据
    function f1() {
        var num = 5;
        return function () {
            num++;
            return num;
        }
    }
    var ff = f1();
    console.log(ff());//6
    console.log(ff());//7
    console.log(ff());//8
</script>
</body>
</html>